package cn.tedu.stage2.day03;

import java.io.*;

/**
 * 将当前目录下的所有文件都复制一份，复制的文件命名为:原
 * 文件名_cp.后缀
 * 比如原文件为:test.dat
 * 复制后的文件为:test_cp.dat
 */
public class Test03 {
    public static void main(String[] args) throws IOException {
        FileInputStream fis = new FileInputStream("test.dat");
        BufferedInputStream bis = new BufferedInputStream(fis,1024*10);

        FileOutputStream fos = new FileOutputStream("test_cp.dat");
        BufferedOutputStream bos = new BufferedOutputStream(fos,1024*10);

        int d;
        long start = System.currentTimeMillis();
        while( (d = bis.read()) != -1 ) {
            bos.write(d);
        }
        long end = System.currentTimeMillis();
        System.out.println("复制完毕!耗时"+(end-start)+"ms");

        bis.close();
        bos.close();
    }
}
